<?xml version="1.0" encoding="UTF-8"?>
<project name="HadoopOptimizer" default="kit">

	<property name="configuration" value="release" />

	<path id="project.class.path">
		<pathelement location="bin" />
		<fileset dir="lib">
			<include name="**/*.jar"/>
		</fileset>
	</path>

	<target name="compile">
		<condition property="isDebug">
			<equals arg1="${configuration}" arg2="debug" />
		</condition>
		<mkdir dir="bin" />
		<delete>
			<fileset dir="bin" includes="**/*" />
		</delete>
		<!-- Why isn't there inline expression evaluation in ant?? -->
		<condition property="debug" value="on">
			<equals arg1="${configuration}" arg2="debug" />
		</condition>
		<!-- Optimizer -->
		<javac srcdir="src" destdir="bin" debug="${debug}">
			<classpath refid="project.class.path"/>
		</javac>
	</target>

	<!-- TODO: add unit tests between compile and documentation -->

	<target name="documentation" depends="compile">
		<mkdir dir="docs" />
		<delete>
			<fileset dir="docs" includes="**/*" />
		</delete>
		<javadoc
				sourcepath="src"
				destdir="docs"
				packagenames="org.dyndns.opendemogroup.*">
			<classpath refid="project.class.path"/>
		</javadoc>
	</target>

	<target name="kit" depends="documentation">
		<mkdir dir="kit" />
		<delete>
			<fileset dir="kit" includes="**/*" />
		</delete>
		<!-- TODO: encode version number in output files -->
		<jar basedir="bin" destfile="kit/hadoopoptimizer.jar" />
		<zip basedir="docs" destfile="kit/hadoopoptimizer-docs.zip" />
		<zip basedir="src" destfile="kit/hadoopoptimizer-src.zip" />
	</target>

	<target name="run" depends="compile">
		<java
			failonerror="true"
			output="run.out"
			error="run.err"
			classname="org.dyndns.opendemogroup.hadoopoptimizer.DistributedRunDriver">
			<classpath refid="project.class.path"/>
			<sysproperty key="javax.xml.parsers.DocumentBuilderFactory" value="com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl" />
			<sysproperty key="javax.xml.parsers.SAXParserFactory" value="com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl" />
		</java>
	</target>

</project>